<template>
  <el-dialog v-model="dialog.visible"
             width="80%"
             :title="dialog.title"
             :before-close="close">
    <avue-crud
        v-if="tableOption"
        v-bind="bindVal"
        v-on="onEvent"
        v-model:page="page"
        v-model="startForm">
      <!-- 菜单按钮 -->
    </avue-crud>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="confirm">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script>
import {createStaticMixin} from "@/mixins/startCrud";
import {deepClone} from "utils/util";
import userOption from "@/option/sys/userOption";
import * as userApi from "@/api/sys/userApi";

const option = {
  option: userOption,
  api: userApi
}
export default {
  name: "sysUserSelectDialog",
  mixins: [createStaticMixin(option)],
  data() {
    return {
      dialog: {
        visible: false,
        title: '请选择用户'
      }
    }
  },
  methods: {
    loadCrudOptionBefore(avueOption) {
      avueOption.selection = true;
      avueOption.menu = false
    },
    show(title = '请选择用户') {
      this.dialog.title = title;
      this.dialog.visible = true;
      this.refreshChange();
    },
    confirm() {
      let selectionRows = this.$refs.startTableCrud.getSelectionRows() || [];
      this.$emit("submit", deepClone(selectionRows), this.close);
    },
    close() {
      this.dialog.visible = false;
    }
  }
}
</script>

<style scoped>

</style>
